package com.exam.controller;

import com.exam.pojo.domain.QuestionDiscuss;
import com.exam.pojo.page.PageResult;
import com.exam.pojo.vo.QuestionDiscussVO;
import com.exam.service.IQuestionDiscussService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/discuss")
@Api(tags = "问题讨论")
@RequiredArgsConstructor
public class QuestionDiscussController {

    private final IQuestionDiscussService questionDiscussService;


    @PostMapping
    @ApiOperation("添加讨论")
    public void add(@RequestBody QuestionDiscuss dto){
        questionDiscussService.add(dto);
    }


    @GetMapping("/{questionId}")
    @ApiOperation("查询问题讨论列表")
    public PageResult<QuestionDiscussVO> list(@PathVariable Long questionId,
                           @RequestParam(required = false,defaultValue = "1") Integer page,
                           @RequestParam(required = false,defaultValue = "50") Integer size){
        return questionDiscussService.queryByQuestionId(questionId,page,size);
    }
}
